<?php

namespace App\Trip\Train\Order;

class OrderCancelResult
{
    private int    $status;
    private string $message;

    public function __construct(int $status, string $msg = "")
    {
        $this->status = $status;
        if ($msg) {
            $this->message = $msg;
        } else {
            $this->message = $this->isSuccess() ? "订票已取消" : "订票取消失败";
        }
    }

    public function isSuccess(): bool
    {
        return $this->getStatus() == 1;
    }

    /**
     * 0 失败 1 成功 -1 不需要取消
     *
     * @return int
     */
    public function getStatus(): int
    {
        return $this->status;
    }

    public function getMessage(): string
    {
        return $this->message;
    }
}